package com.example.mybatisfinaltask.service.impl;

import com.example.mybatisfinaltask.mapper.DeptMapper;
import com.example.mybatisfinaltask.pojo.Dept;
import com.example.mybatisfinaltask.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;
@Service
public class DeptServiceImpl implements DeptService {
    @Autowired
    DeptMapper deptMapper;
    @Override
    public List<Dept> selectAll() {
        return deptMapper.select();
    }

    @Override
    public void deleteById(Integer id) {
        deptMapper.deleteById(id);
    }

    @Override
    public void add(Dept dept) {
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.add(dept);
    }

    @Override
    public Dept getById(Integer id) {
        return deptMapper.getById(id);
    }

    @Override
    public Dept modify(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.modify(dept);
        return null;
    }
}
